package com.sam.im.heiqun.utils;

import android.support.annotation.Nullable;

import com.alibaba.fastjson.JSON;

/**
 * Created by zhangqiang on 2018/7/10.
 */
public class JsonUtil {

    @Nullable
    public static <T> T toObject(String  jsonString,Class<T> tClass){

        try {

            return JSON.parseObject(jsonString,tClass);
        }catch (Throwable t){
            t.printStackTrace();
        }
        return null;
    }

    @Nullable
    public static String toJson(Object o){

        try {
            return JSON.toJSONString(o);
        }catch (Throwable t){
            t.printStackTrace();
        }
        return null;
    }

}
